<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
  <head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->

    <base href="<%=basePath%>">
    
    <title>学生管理系统登录</title>
	<link rel="stylesheet" href="/css/bootstrap.min.css" >
	<link rel="stylesheet" type="text/css" href="/css/bootstrap-theme.min.css">
	<style>
	
	body {
  padding-top: 40px;
  padding-bottom: 40px;
  background-color: #eee;
}

.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
  margin-bottom: 10px;
}
.form-signin .checkbox {
  font-weight: normal;
}
.form-signin .form-control {
  position: relative;
  height: auto;
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
  padding: 10px;
  font-size: 16px;
}
.form-signin .form-control:focus {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
	
	
	</style>
		

  </head>
  
  <body>
    <!-- <h1>登录页面</h1>
		
<form action="login" method="POST">
<table>
<tr>
<td>用户名：</td>
<td><input type="text" name="user.username"/></td>

</tr>

<tr>
<td>密码：</td>
<td>
	<input type="password" name="user.pass"/>
</td>

</tr>

<tr>
<td>验证码</td>
<td> <input type="text" name="kaptcha" value="" /><img src="kaptcha.jpg" /></td>

</tr>


<tr>
<td>
	<input type="button" value="登录" onclick="login();"/>
</td>

<td>
	<input type="reset" value="重置"/>
</td>

</tr>
</table>
</form>

<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
function login(){
	
	var username=$('input[name="user.username"]').val();
	var password=$('input[name="user.pass"]').val();
	var kaptcha=$('input[name="kaptcha"]').val();
	
	if(username!=""&&password!=""){
		
		$.ajax({
			   type: "POST",
			   url: "/rbac/login",
			   data: {
				   "user.username":username,
				   "user.pass":password,
				   "kaptcha":kaptcha
				   
			   },
			   dataType: "json",
			   success: function(result){
				   if(result.msg=="ok"){
					   window.location.href='/rbac/admin.jsp';
				   }
				   else if(result.msg="errorkaptcha"){
					   alert('验证码输入错误，请刷新后重试');
				   }
				   else{
					   alert('用户名或是密码错误');
				   }
				   
			     
			   }
			});
		
	}
	else{
		alert('用户名和密码不能为空');
	}
	
	
	
	
	
	
	
}



</script> -->

<div class="container">

	<form class="form-signin">
	  <h2 class="form-signin-heading">学生信息管理系统</h2>
	  <label for="inputEmail" class="sr-only">用户名</label>
	  <input type="email" id="inputEmail" class="form-control" placeholder="用户名" name="user.username" required autofocus>
	  <label for="inputPassword" class="sr-only">密码</label>
	  <input type="password" id="inputPassword" class="form-control" placeholder="密码" required name="user.pass" > 
	  <div class="checkbox">
	

			<input type="text" name="kaptcha" value=""  class="form-control" placeholder="请输入验证码"/><img src="kaptcha.jpg" />

	  </div>
	  <button class="btn btn-lg btn-primary btn-block" type="button" onclick="login();">登录</button>
	</form>

  </div> <!-- /container -->




  <script type="text/javascript" src="/js/jquery.min.js"></script>
  <script type="text/javascript">
  function login(){
	  
	  var username=$('input[name="user.username"]').val();
	  var password=$('input[name="user.pass"]').val();
	  var kaptcha=$('input[name="kaptcha"]').val();
	  
	  if(username!=""&&password!=""){
		  
		  $.ajax({
				 type: "POST",
				 url: "/rbac/login",
				 data: {
					 "user.username":username,
					 "user.pass":password,
					 "kaptcha":kaptcha
					 
				 },
				 dataType: "json",
				 success: function(result){
					 if(result.msg=="ok"){
						 window.location.href='/manage/main.jsp';
					 }
					 else if(result.msg="errorkaptcha"){
						 alert('验证码输入错误，请刷新后重试');
					 }
					 else{
						 alert('用户名或是密码错误');
					 }
					 
				   
				 }
			  });
		  
	  }
	  else{
		  alert('用户名和密码不能为空');
	  }
	  
	  
	  
	  
	  
	  
	  
  }
  
  
  
  </script> 
  </body>
</html>
